################## Marginal Means by tax ###############
#rate 15% DE
taxmm15DE <- mm(subset(df_conj, country == "DE" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

plot(taxmm15DE)

taxmm15DE$att <- factor(taxmm15DE$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                      "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                      "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                      "5) Never restricted", "4) 1 day per week", "3) 3 days per week", "2) 5 days per week", "1) Always restricted", 
                                                      "3) No new requirements", "2) At least 40 miles per gallon ", "1) At least 55 miles per gallon ",
                                                      "3) No increase of support", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                      "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                      labels = c(rev(c("Increasing prices by 15%",
                                       "General\r\nbudget", "Env. & climate\r\nprotection", "Low-income\r\nhouseholds", "Reduce\r\nincome taxes",
                                       "Keep at\r\ncurrent level", "Halving\r\nsubsidies", "Eliminating\r\nsubsidies",
                                       "Never\r\nrestricted", "1 day\r\nper week", "3 days\r\nper week", "5 days\r\nper week", "Always\r\nrestricted", 
                                       "No new\r\nrequirements", "Max. consumption\r\nof 5.9 l/100km", "Max. consumption\r\nof 4.3 l/100kmm",
                                       "No increase\r\nof support", "Reducing prices\r\nby 15%", "Reducing prices\r\nby 30%",
                                       "No\r\ncampaigns", "Occasional\r\ncampaigns", "Frequent\r\ncampaigns"))))

taxmm15DE$poltyp <- factor(ifelse(taxmm15DE$att == "No new tax" |  taxmm15DE$att == "Increasing prices by 15%" |  taxmm15DE$att == "Increasing prices by 30%" | 
                                  taxmm15DE$att == "General\r\nbudget" | taxmm15DE$att == "Env. & climate\r\nprotection" | taxmm15DE$att == "Low-income\r\nhouseholds" | taxmm15DE$att == "Reduce\r\nincome taxes" | taxmm15DE$att == "No tax revenues" |
                                  taxmm15DE$att == "Keep at\r\ncurrent level" | taxmm15DE$att == "Halving\r\nsubsidies" | taxmm15DE$att == "Eliminating\r\nsubsidies",
                                "Market-based push", ifelse(
                                  taxmm15DE$att == "Never\r\nrestricted" | taxmm15DE$att == "1 day\r\nper week" | taxmm15DE$att == "3 day\r\nper week" | taxmm15DE$att == "5 days\r\nper week" | taxmm15DE$att == "Always\r\nrestricted" | 
                                    taxmm15DE$att == "No new\r\nrequirements" | taxmm15DE$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm15DE$att == "Max. consumption\r\nof 4.3 l/100km",
                                  "Non-market-based push", ifelse(
                                    taxmm15DE$att == "No\r\ncampaigns" | taxmm15DE$att == "Occasional\r\ncampaigns" | taxmm15DE$att == "Frequent\r\ncampaigns", 
                                    "Non-market-based pull", ifelse(
                                      taxmm15DE$att == "No increase\r\nof support" | taxmm15DE$att == "Reducing prices\r\nby 15%" | taxmm15DE$att == "Reducing prices\r\nby 30%",
                                      "Market-based pull", "Other Policy Features")))))

taxmm15DE$policy <- ifelse(taxmm15DE$att == "No new tax" |  taxmm15DE$att == "Increasing prices by 15%" |  taxmm15DE$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15DE$att == "General\r\nbudget" | taxmm15DE$att == "Env. & climate\r\nprotection" | taxmm15DE$att == "Low-income\r\nhouseholds" | taxmm15DE$att == "Reduce\r\nincome taxes" | taxmm15DE$att == "No tax revenues", "2", ifelse(
    taxmm15DE$att == "Keep at\r\ncurrent level" | taxmm15DE$att == "Halving\r\nsubsidies" | taxmm15DE$att == "Eliminating\r\nsubsidies", "3", ifelse(
      taxmm15DE$att == "Never\r\nrestricted" | taxmm15DE$att == "1 day\r\nper week" | taxmm15DE$att == "3 days\r\nper week" | taxmm15DE$att == "5 days\r\nper week" | taxmm15DE$att == "Always\r\nrestricted", "4", ifelse(
        taxmm15DE$att == "No new\r\nrequirements" | taxmm15DE$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm15DE$att == "Max. consumption\r\nof 4.3 l/100km", "5", ifelse(
          taxmm15DE$att == "No\r\ncampaigns" | taxmm15DE$att == "Occasional\r\ncampaigns" | taxmm15DE$att == "Frequent\r\ncampaigns", "6", ifelse(
            taxmm15DE$att == "No increase\r\nof support" | taxmm15DE$att == "Reducing prices\r\nby 15%" | taxmm15DE$att == "Reducing prices\r\nby 30%", "7",
            "8")))))))

taxmm15DE$policy = factor(taxmm15DE$policy, levels=c(1:8), labels=c("Tax","Earmarking","Industry Subsidy", "Access restriction", "Standards", "Campaign", "PT prices", "Other"))


#rate 30% DE
taxmm30DE <- mm(subset(df_conj, country == "DE" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

plot(taxmm30DE)

taxmm30DE$att <- factor(taxmm30DE$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                      "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                      "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                      "5) Never restricted", "4) 1 day per week", "3) 3 days per week", "2) 5 days per week", "1) Always restricted", 
                                                      "3) No new requirements", "2) At least 40 miles per gallon ", "1) At least 55 miles per gallon ",
                                                      "3) No increase of support", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                      "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                      labels = c(rev(c("Increasing prices by 15%",
                                       "General\r\nbudget", "Env. & climate\r\nprotection", "Low-income\r\nhouseholds", "Reduce\r\nincome taxes",
                                       "Keep at\r\ncurrent level", "Halving\r\nsubsidies", "Eliminating\r\nsubsidies",
                                       "Never\r\nrestricted", "1 day\r\nper week", "3 days\r\nper week", "5 days\r\nper week", "Always\r\nrestricted", 
                                       "No new\r\nrequirements", "Max. consumption\r\nof 5.9 l/100km", "Max. consumption\r\nof 4.3 l/100km",
                                       "No increase\r\nof support", "Reducing prices\r\nby 15%", "Reducing prices\r\nby 30%",
                                       "No\r\ncampaigns", "Occasional\r\ncampaigns", "Frequent\r\ncampaigns"))))

taxmm30DE$poltyp <- factor(ifelse(taxmm30DE$att == "No new tax" |  taxmm30DE$att == "Increasing prices by 15%" |  taxmm30DE$att == "Increasing prices by 30%" | 
                                  taxmm30DE$att == "General\r\nbudget" | taxmm30DE$att == "Env. & climate\r\nprotection" | taxmm30DE$att == "Low-income\r\nhouseholds" | taxmm30DE$att == "Reduce\r\nincome taxes" | taxmm30DE$att == "No tax revenues" |
                                  taxmm30DE$att == "Keep at\r\ncurrent level" | taxmm30DE$att == "Halving\r\nsubsidies" | taxmm30DE$att == "Eliminating\r\nsubsidies",
                                "Market-based push", ifelse(
                                  taxmm30DE$att == "Never\r\nrestricted" | taxmm30DE$att == "1 day\r\nper week" | taxmm30DE$att == "3 day\r\nper week" | taxmm30DE$att == "5 days\r\nper week" | taxmm30DE$att == "Always\r\nrestricted" | 
                                    taxmm30DE$att == "No new\r\nrequirements" | taxmm30DE$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm30DE$att == "Max. consumption\r\nof 4.3 l/100km",
                                  "Non-market-based push", ifelse(
                                    taxmm30DE$att == "No\r\ncampaigns" | taxmm30DE$att == "Occasional\r\ncampaigns" | taxmm30DE$att == "Frequent\r\ncampaigns", 
                                    "Non-market-based pull", ifelse(
                                      taxmm30DE$att == "No increase\r\nof support" | taxmm30DE$att == "Reducing prices\r\nby 15%" | taxmm30DE$att == "Reducing prices\r\nby 30%",
                                      "Market-based pull", "Other Policy Features")))))

taxmm30DE$policy <- ifelse(taxmm30DE$att == "No new tax" |  taxmm30DE$att == "Increasing prices by 15%" |  taxmm30DE$att == "Increasing prices by 30%", "1", ifelse(
  taxmm30DE$att == "General\r\nbudget" | taxmm30DE$att == "Env. & climate\r\nprotection" | taxmm30DE$att == "Low-income\r\nhouseholds" | taxmm30DE$att == "Reduce\r\nincome taxes" | taxmm30DE$att == "No tax revenues", "2", ifelse(
    taxmm30DE$att == "Keep at\r\ncurrent level" | taxmm30DE$att == "Halving\r\nsubsidies" | taxmm30DE$att == "Eliminating\r\nsubsidies", "3", ifelse(
      taxmm30DE$att == "Never\r\nrestricted" | taxmm30DE$att == "1 day\r\nper week" | taxmm30DE$att == "3 days\r\nper week" | taxmm30DE$att == "5 days\r\nper week" | taxmm30DE$att == "Always\r\nrestricted", "4", ifelse(
        taxmm30DE$att == "No new\r\nrequirements" | taxmm30DE$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm30DE$att == "Max. consumption\r\nof 4.3 l/100km", "5", ifelse(
          taxmm30DE$att == "No\r\ncampaigns" | taxmm30DE$att == "Occasional\r\ncampaigns" | taxmm30DE$att == "Frequent\r\ncampaigns", "6", ifelse(
            taxmm30DE$att == "No increase\r\nof support" | taxmm30DE$att == "Reducing prices\r\nby 15%" | taxmm30DE$att == "Reducing prices\r\nby 30%", "7",
            "8")))))))

taxmm30DE$policy = factor(taxmm30DE$policy, levels=c(1:8), labels=c("Tax","Earmarking","Industry Subsidy", "Access restriction", "Standards", "Campaign", "PT prices", "Other"))

#rate 15% CN
taxmm15CN <- mm(subset(df_conj, country == "CN" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                                                                                                                attrib4_lab + attrib6_lab, id = ~id, CNsign=design, baselines = baselines_base)

plot(taxmm15CN)

taxmm15CN$att <- factor(taxmm15CN$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "5) Never restricted", "4) 1 day per week", "3) 3 days per week", "2) 5 days per week", "1) Always restricted", 
                                                          "3) No new requirements", "2) At least 40 miles per gallon ", "1) At least 55 miles per gallon ",
                                                          "3) No increase of support", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\r\nbudget", "Env. & climate\r\nprotection", "Low-income\r\nhouseholds", "Reduce\r\nincome taxes",
                                         "Keep at\r\ncurrent level", "Halving\r\nsubsidies", "Eliminating\r\nsubsidies",
                                         "Never\r\nrestricted", "1 day\r\nper week", "3 days\r\nper week", "5 days\r\nper week", "Always\r\nrestricted", 
                                         "No new\r\nrequirements", "Max. consumption\r\nof 5.9 l/100km", "Max. consumption\r\nof 4.3 l/100km",
                                         "No increase\r\nof support", "Reducing prices\r\nby 15%", "Reducing prices\r\nby 30%",
                                         "No\r\ncampaigns", "Occasional\r\ncampaigns", "Frequent\r\ncampaigns"))))

taxmm15CN$poltyp <- factor(ifelse(taxmm15CN$att == "No new tax" |  taxmm15CN$att == "Increasing prices by 15%" |  taxmm15CN$att == "Increasing prices by 30%" | 
                                    taxmm15CN$att == "General\r\nbudget" | taxmm15CN$att == "Env. & climate\r\nprotection" | taxmm15CN$att == "Low-income\r\nhouseholds" | taxmm15CN$att == "Reduce\r\nincome taxes" | taxmm15CN$att == "No tax revenues" |
                                    taxmm15CN$att == "Keep at\r\ncurrent level" | taxmm15CN$att == "Halving\r\nsubsidies" | taxmm15CN$att == "Eliminating\r\nsubsidies",
                                  "Market-based push", ifelse(
                                    taxmm15CN$att == "Never\r\nrestricted" | taxmm15CN$att == "1 day\r\nper week" | taxmm15CN$att == "3 day\r\nper week" | taxmm15CN$att == "5 days\r\nper week" | taxmm15CN$att == "Always\r\nrestricted" | 
                                      taxmm15CN$att == "No new\r\nrequirements" | taxmm15CN$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm15CN$att == "Max. consumption\r\nof 4.3 l/100km",
                                    "Non-market-based push", ifelse(
                                      taxmm15CN$att == "No\r\ncampaigns" | taxmm15CN$att == "Occasional\r\ncampaigns" | taxmm15CN$att == "Frequent\r\ncampaigns", 
                                      "Non-market-based pull", ifelse(
                                        taxmm15CN$att == "No increase\r\nof support" | taxmm15CN$att == "Reducing prices\r\nby 15%" | taxmm15CN$att == "Reducing prices\r\nby 30%",
                                        "Market-based pull", "Other Policy Features")))))

taxmm15CN$policy <- ifelse(taxmm15CN$att == "No new tax" |  taxmm15CN$att == "Increasing prices by 15%" |  taxmm15CN$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15CN$att == "General\r\nbudget" | taxmm15CN$att == "Env. & climate\r\nprotection" | taxmm15CN$att == "Low-income\r\nhouseholds" | taxmm15CN$att == "Reduce\r\nincome taxes" | taxmm15CN$att == "No tax revenues", "2", ifelse(
    taxmm15CN$att == "Keep at\r\ncurrent level" | taxmm15CN$att == "Halving\r\nsubsidies" | taxmm15CN$att == "Eliminating\r\nsubsidies", "3", ifelse(
      taxmm15CN$att == "Never\r\nrestricted" | taxmm15CN$att == "1 day\r\nper week" | taxmm15CN$att == "3 days\r\nper week" | taxmm15CN$att == "5 days\r\nper week" | taxmm15CN$att == "Always\r\nrestricted", "4", ifelse(
        taxmm15CN$att == "No new\r\nrequirements" | taxmm15CN$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm15CN$att == "Max. consumption\r\nof 4.3 l/100km", "5", ifelse(
          taxmm15CN$att == "No\r\ncampaigns" | taxmm15CN$att == "Occasional\r\ncampaigns" | taxmm15CN$att == "Frequent\r\ncampaigns", "6", ifelse(
            taxmm15CN$att == "No increase\r\nof support" | taxmm15CN$att == "Reducing prices\r\nby 15%" | taxmm15CN$att == "Reducing prices\r\nby 30%", "7",
            "8")))))))

taxmm15CN$policy = factor(taxmm15CN$policy, levels=c(1:8), labels=c("Tax","Earmarking","Industry Subsidy", "Access restriction", "Standards", "Campaign", "PT prices", "Other"))


#rate 30% CN
taxmm30CN <- mm(subset(df_conj, country == "CN" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                                                                                                                attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

plot(taxmm30CN)

taxmm30CN$att <- factor(taxmm30CN$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "5) Never restricted", "4) 1 day per week", "3) 3 days per week", "2) 5 days per week", "1) Always restricted", 
                                                          "3) No new requirements", "2) At least 40 miles per gallon ", "1) At least 55 miles per gallon ",
                                                          "3) No increase of support", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\r\nbudget", "Env. & climate\r\nprotection", "Low-income\r\nhouseholds", "Reduce\r\nincome taxes",
                                         "Keep at\r\ncurrent level", "Halving\r\nsubsidies", "Eliminating\r\nsubsidies",
                                         "Never\r\nrestricted", "1 day\r\nper week", "3 days\r\nper week", "5 days\r\nper week", "Always\r\nrestricted", 
                                         "No new\r\nrequirements", "Max. consumption\r\nof 5.9 l/100km", "Max. consumption\r\nof 4.3 l/100km",
                                         "No increase\r\nof support", "Reducing prices\r\nby 15%", "Reducing prices\r\nby 30%",
                                         "No\r\ncampaigns", "Occasional\r\ncampaigns", "Frequent\r\ncampaigns"))))

taxmm30CN$poltyp <- factor(ifelse(taxmm30CN$att == "No new tax" |  taxmm30CN$att == "Increasing prices by 15%" |  taxmm30CN$att == "Increasing prices by 30%" | 
                                    taxmm30CN$att == "General\r\nbudget" | taxmm30CN$att == "Env. & climate\r\nprotection" | taxmm30CN$att == "Low-income\r\nhouseholds" | taxmm30CN$att == "Reduce\r\nincome taxes" | taxmm30CN$att == "No tax revenues" |
                                    taxmm30CN$att == "Keep at\r\ncurrent level" | taxmm30CN$att == "Halving\r\nsubsidies" | taxmm30CN$att == "Eliminating\r\nsubsidies",
                                  "Market-based push", ifelse(
                                    taxmm30CN$att == "Never\r\nrestricted" | taxmm30CN$att == "1 day\r\nper week" | taxmm30CN$att == "3 day\r\nper week" | taxmm30CN$att == "5 days\r\nper week" | taxmm30CN$att == "Always\r\nrestricted" | 
                                      taxmm30CN$att == "No new\r\nrequirements" | taxmm30CN$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm30CN$att == "Max. consumption\r\nof 4.3 l/100km",
                                    "Non-market-based push", ifelse(
                                      taxmm30CN$att == "No\r\ncampaigns" | taxmm30CN$att == "Occasional\r\ncampaigns" | taxmm30CN$att == "Frequent\r\ncampaigns", 
                                      "Non-market-based pull", ifelse(
                                        taxmm30CN$att == "No increase\r\nof support" | taxmm30CN$att == "Reducing prices\r\nby 15%" | taxmm30CN$att == "Reducing prices\r\nby 30%",
                                        "Market-based pull", "Other Policy Features")))))

taxmm30CN$policy <- ifelse(taxmm30CN$att == "No new tax" |  taxmm30CN$att == "Increasing prices by 15%" |  taxmm30CN$att == "Increasing prices by 30%", "1", ifelse(
  taxmm30CN$att == "General\r\nbudget" | taxmm30CN$att == "Env. & climate\r\nprotection" | taxmm30CN$att == "Low-income\r\nhouseholds" | taxmm30CN$att == "Reduce\r\nincome taxes" | taxmm30CN$att == "No tax revenues", "2", ifelse(
    taxmm30CN$att == "Keep at\r\ncurrent level" | taxmm30CN$att == "Halving\r\nsubsidies" | taxmm30CN$att == "Eliminating\r\nsubsidies", "3", ifelse(
      taxmm30CN$att == "Never\r\nrestricted" | taxmm30CN$att == "1 day\r\nper week" | taxmm30CN$att == "3 days\r\nper week" | taxmm30CN$att == "5 days\r\nper week" | taxmm30CN$att == "Always\r\nrestricted", "4", ifelse(
        taxmm30CN$att == "No new\r\nrequirements" | taxmm30CN$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm30CN$att == "Max. consumption\r\nof 4.3 l/100km", "5", ifelse(
          taxmm30CN$att == "No\r\ncampaigns" | taxmm30CN$att == "Occasional\r\ncampaigns" | taxmm30CN$att == "Frequent\r\ncampaigns", "6", ifelse(
            taxmm30CN$att == "No increase\r\nof support" | taxmm30CN$att == "Reducing prices\r\nby 15%" | taxmm30CN$att == "Reducing prices\r\nby 30%", "7",
            "8")))))))

taxmm30CN$policy = factor(taxmm30CN$policy, levels=c(1:8), labels=c("Tax","Earmarking","Industry Subsidy", "Access restriction", "Standards", "Campaign", "PT prices", "Other"))

#rate 15% US
taxmm15US <- mm(subset(df_conj, country == "US" & attrib1_lab %in% c("2) Increasing prices by 15%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                                                                                                                attrib4_lab + attrib6_lab, id = ~id, CNsign=design, baselines = baselines_base)

plot(taxmm15US)

taxmm15US$att <- factor(taxmm15US$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "5) Never restricted", "4) 1 day per week", "3) 3 days per week", "2) 5 days per week", "1) Always restricted", 
                                                          "3) No new requirements", "2) At least 40 miles per gallon ", "1) At least 55 miles per gallon ",
                                                          "3) No increase of support", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\r\nbudget", "Env. & climate\r\nprotection", "Low-income\r\nhouseholds", "Reduce\r\nincome taxes",
                                         "Keep at\r\ncurrent level", "Halving\r\nsubsidies", "Eliminating\r\nsubsidies",
                                         "Never\r\nrestricted", "1 day\r\nper week", "3 days\r\nper week", "5 days\r\nper week", "Always\r\nrestricted", 
                                         "No new\r\nrequirements", "Max. consumption\r\nof 5.9 l/100km", "Max. consumption\r\nof 4.3 l/100km",
                                         "No increase\r\nof support", "Reducing prices\r\nby 15%", "Reducing prices\r\nby 30%",
                                         "No\r\ncampaigns", "Occasional\r\ncampaigns", "Frequent\r\ncampaigns"))))

taxmm15US$poltyp <- factor(ifelse(taxmm15US$att == "No new tax" |  taxmm15US$att == "Increasing prices by 15%" |  taxmm15US$att == "Increasing prices by 30%" | 
                                    taxmm15US$att == "General\r\nbudget" | taxmm15US$att == "Env. & climate\r\nprotection" | taxmm15US$att == "Low-income\r\nhouseholds" | taxmm15US$att == "Reduce\r\nincome taxes" | taxmm15US$att == "No tax revenues" |
                                    taxmm15US$att == "Keep at\r\ncurrent level" | taxmm15US$att == "Halving\r\nsubsidies" | taxmm15US$att == "Eliminating\r\nsubsidies",
                                  "Market-based push", ifelse(
                                    taxmm15US$att == "Never\r\nrestricted" | taxmm15US$att == "1 day\r\nper week" | taxmm15US$att == "3 day\r\nper week" | taxmm15US$att == "5 days\r\nper week" | taxmm15US$att == "Always\r\nrestricted" | 
                                      taxmm15US$att == "No new\r\nrequirements" | taxmm15US$att == "40 miles\r\nper gallon" | taxmm15US$att == "55 miles\r\nper gallon",
                                    "Non-market-based push", ifelse(
                                      taxmm15US$att == "No\r\ncampaigns" | taxmm15US$att == "Occasional\r\ncampaigns" | taxmm15US$att == "Frequent\r\ncampaigns", 
                                      "Non-market-based pull", ifelse(
                                        taxmm15US$att == "No increase\r\nof support" | taxmm15US$att == "Reducing prices\r\nby 15%" | taxmm15US$att == "Reducing prices\r\nby 30%",
                                        "Market-based pull", "Other Policy Features")))))

taxmm15US$policy <- ifelse(taxmm15US$att == "No new tax" |  taxmm15US$att == "Increasing prices by 15%" |  taxmm15US$att == "Increasing prices by 30%", "1", ifelse(
  taxmm15US$att == "General\r\nbudget" | taxmm15US$att == "Env. & climate\r\nprotection" | taxmm15US$att == "Low-income\r\nhouseholds" | taxmm15US$att == "Reduce\r\nincome taxes" | taxmm15US$att == "No tax revenues", "2", ifelse(
    taxmm15US$att == "Keep at\r\ncurrent level" | taxmm15US$att == "Halving\r\nsubsidies" | taxmm15US$att == "Eliminating\r\nsubsidies", "3", ifelse(
      taxmm15US$att == "Never\r\nrestricted" | taxmm15US$att == "1 day\r\nper week" | taxmm15US$att == "3 days\r\nper week" | taxmm15US$att == "5 days\r\nper week" | taxmm15US$att == "Always\r\nrestricted", "4", ifelse(
        taxmm15US$att == "No new\r\nrequirements" | taxmm15US$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm15US$att == "Max. consumption\r\nof 4.3 l/100km", "5", ifelse(
          taxmm15US$att == "No\r\ncampaigns" | taxmm15US$att == "Occasional\r\ncampaigns" | taxmm15US$att == "Frequent\r\ncampaigns", "6", ifelse(
            taxmm15US$att == "No increase\r\nof support" | taxmm15US$att == "Reducing prices\r\nby 15%" | taxmm15US$att == "Reducing prices\r\nby 30%", "7",
            "8")))))))

taxmm15US$policy = factor(taxmm15US$policy, levels=c(1:8), labels=c("Tax","Earmarking","Industry Subsidy", "Access restriction", "Standards", "Campaign", "PT prices", "Other"))


#rate 30% US
taxmm30US <- mm(subset(df_conj, country == "US" & attrib1_lab %in% c("1) Increasing prices by 30%")), rate ~ attrib1_lab +  attrib2_lab +  attrib7_lab +  attrib3_lab + attrib5_lab +  
                                                                                                                attrib4_lab + attrib6_lab, id = ~id, design=design, baselines = baselines_base)

plot(taxmm30US)

taxmm30US$att <- factor(taxmm30US$level, levels = c(rev(c("2) Increasing prices by 15%",
                                                          "2) General government budget", "1) Public environmental and climate protection programs", "3) Public programs for low-income households", "4) Reduce income taxes",
                                                          "3) Keeping subsidies at current level", "2) Halving subsidies ", "1) Eliminating subsidies",
                                                          "5) Never restricted", "4) 1 day per week", "3) 3 days per week", "2) 5 days per week", "1) Always restricted", 
                                                          "3) No new requirements", "2) At least 40 miles per gallon ", "1) At least 55 miles per gallon ",
                                                          "3) No increase of support", "2) Reducing prices by 15%", "1) Reducing prices by 30%",
                                                          "3) No campaigns", "2) Occasional campaigns", "1) Frequent campaigns"))),
                        labels = c(rev(c("Increasing prices by 15%",
                                         "General\r\nbudget", "Env. & climate\r\nprotection", "Low-income\r\nhouseholds", "Reduce\r\nincome taxes",
                                         "Keep at\r\ncurrent level", "Halving\r\nsubsidies", "Eliminating\r\nsubsidies",
                                         "Never\r\nrestricted", "1 day\r\nper week", "3 days\r\nper week", "5 days\r\nper week", "Always\r\nrestricted", 
                                         "No new\r\nrequirements", "40 miles\r\nper gallon", "55 miles\r\nper gallon",
                                         "No increase\r\nof support", "Reducing prices\r\nby 15%", "Reducing prices\r\nby 30%",
                                         "No\r\ncampaigns", "Occasional\r\ncampaigns", "Frequent\r\ncampaigns"))))

taxmm30US$poltyp <- factor(ifelse(taxmm30US$att == "No new tax" |  taxmm30US$att == "Increasing prices by 15%" |  taxmm30US$att == "Increasing prices by 30%" | 
                                    taxmm30US$att == "General\r\nbudget" | taxmm30US$att == "Env. & climate\r\nprotection" | taxmm30US$att == "Low-income\r\nhouseholds" | taxmm30US$att == "Reduce\r\nincome taxes" | taxmm30US$att == "No tax revenues" |
                                    taxmm30US$att == "Keep at\r\ncurrent level" | taxmm30US$att == "Halving\r\nsubsidies" | taxmm30US$att == "Eliminating\r\nsubsidies",
                                  "Market-based push", ifelse(
                                    taxmm30US$att == "Never\r\nrestricted" | taxmm30US$att == "1 day\r\nper week" | taxmm30US$att == "3 day\r\nper week" | taxmm30US$att == "5 days\r\nper week" | taxmm30US$att == "Always\r\nrestricted" | 
                                      taxmm30US$att == "No new\r\nrequirements" | taxmm30US$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm30US$att == "Max. consumption\r\nof 4.3 l/100km",
                                    "Non-market-based push", ifelse(
                                      taxmm30US$att == "No\r\ncampaigns" | taxmm30US$att == "Occasional\r\ncampaigns" | taxmm30US$att == "Frequent\r\ncampaigns", 
                                      "Non-market-based pull", ifelse(
                                        taxmm30US$att == "No increase\r\nof support" | taxmm30US$att == "Reducing prices\r\nby 15%" | taxmm30US$att == "Reducing prices\r\nby 30%",
                                        "Market-based pull", "Other Policy Features")))))

taxmm30US$policy <- ifelse(taxmm30US$att == "No new tax" |  taxmm30US$att == "Increasing prices by 15%" |  taxmm30US$att == "Increasing prices by 30%", "1", ifelse(
  taxmm30US$att == "General\r\nbudget" | taxmm30US$att == "Env. & climate\r\nprotection" | taxmm30US$att == "Low-income\r\nhouseholds" | taxmm30US$att == "Reduce\r\nincome taxes" | taxmm30US$att == "No tax revenues", "2", ifelse(
    taxmm30US$att == "Keep at\r\ncurrent level" | taxmm30US$att == "Halving\r\nsubsidies" | taxmm30US$att == "Eliminating\r\nsubsidies", "3", ifelse(
      taxmm30US$att == "Never\r\nrestricted" | taxmm30US$att == "1 day\r\nper week" | taxmm30US$att == "3 days\r\nper week" | taxmm30US$att == "5 days\r\nper week" | taxmm30US$att == "Always\r\nrestricted", "4", ifelse(
        taxmm30US$att == "No new\r\nrequirements" | taxmm30US$att == "Max. consumption\r\nof 5.9 l/100km" | taxmm30US$att == "Max. consumption\r\nof 4.3 l/100km", "5", ifelse(
          taxmm30US$att == "No\r\ncampaigns" | taxmm30US$att == "Occasional\r\ncampaigns" | taxmm30US$att == "Frequent\r\ncampaigns", "6", ifelse(
            taxmm30US$att == "No increase\r\nof support" | taxmm30US$att == "Reducing prices\r\nby 15%" | taxmm30US$att == "Reducing prices\r\nby 30%", "7",
            "8")))))))

taxmm30US$policy = factor(taxmm30US$policy, levels=c(1:8), labels=c("Tax","Earmarking","Industry Subsidy", "Access restriction", "Standards", "Campaign", "PT prices", "Other"))


###graph###
df_taxmmt <- rbind(taxmm15DE, taxmm15US, taxmm15CN, taxmm30DE, taxmm30US, taxmm30CN)
df_taxmmt$tax <- rep(c("Increasing prices by 15%", "Increasing prices by 15%", "Increasing prices by 15%", "Increasing prices by 30%", "Increasing prices by 30%", "Increasing prices by 30%"), each=nrow(taxmm15DE))
df_taxmmt$country <- rep(c("Germany", "USA", "China", "Germany", "USA", "China"), each=nrow(taxmm15DE))

taxmm2 <- ggplot(subset(df_taxmmt, policy=="Earmarking"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="bottom", axis.text.y=element_text(size=12), axis.title.y=element_text(size=16),
        legend.text=element_text(size=16), legend.title=element_text(size=16),
        strip.text.x = element_text(size = 16)) +
  ylab("Marginal Mean (Rating)") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm2

legendtaxmm <- get_legend(taxmm2)
taxmm2 <- taxmm2 + theme(legend.position="none")

taxmm3 <- ggplot(subset(df_taxmmt, policy=="Industry Subsidy"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm3

taxmm4 <- ggplot(subset(df_taxmmt, policy=="Access restriction"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm4

taxmm5 <- ggplot(subset(df_taxmmt, policy=="Standards"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_text(size=12), axis.title.y=element_text(size=16), strip.text.x = element_text(size = 16)) +
  ylab("Marginal Mean (Rating)") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm5

taxmm6 <- ggplot(subset(df_taxmmt, policy=="Campaign"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm6

taxmm7 <- ggplot(subset(df_taxmmt, policy=="PT prices"), aes(x=att, y = estimate, group = tax, shape = tax, colour = country)) +
  geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), position = position_dodge(width=.2)) +
  theme_bw() + 
  theme(legend.position="none", axis.text.y=element_blank(), strip.text.x = element_text(size = 16)) +
  ylab("") +
  xlab("") +
  coord_cartesian(ylim = c(3, 5.5)) +
  geom_hline(yintercept = 4, lty="dashed") +
  geom_hline(yintercept = 5, lty="dashed") +
  scale_color_manual(name="Country", values = c("USA" = "#b2abd2", "Germany" = "#5e3c99", "China" = "#e66101"), labels=c("US" = "USA", "DE" = "Germany", "CN" = "China")) +
  scale_shape_discrete(name="Tax") + 
  facet_grid(. ~ policy, scales = "fix")
taxmm7


fig_taxmm1 <- ggdraw() +
  draw_plot(taxmm2, x = 0, y = 0.52, width = 0.34, height = 0.48) +
  draw_plot(taxmm3, x = 0.34, y = 0.52, width = 0.33, height = 0.48) +
  draw_plot(taxmm4, x = 0.67, y = 0.52, width = 0.33, height = 0.48) +
  draw_plot(taxmm5, x = 0, y = 0.04, width = 0.34, height = 0.48) +
  draw_plot(taxmm6, x = 0.34, y = 0.04, width = 0.33, height = 0.48) +
  draw_plot(taxmm7, x = 0.67, y = 0.04, width = 0.33, height = 0.48) +
  draw_plot(legendtaxmm, x = 0, y = 0, width = 1, height = 0.04)
fig_taxmm1

ggsave(filename = "./figs/fig_taxmm1.png", fig_taxmm1, width = 12, height = 9)
